﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace Caifu.WebSite
{
	public static class WebSiteUtil
	{
		public static string GetGrowthCss(object rate)
		{
			double result;
			if (!Double.TryParse(rate.ToString(), out result)) result = 0;

			return GetGrowthCss(result);
		}

		public static string GetGrowthCss(double rate)
		{
			if (rate > 0) return "red";
			if (rate < 0) return "green";
			return "";
		}

		public static string FormatGrowthRate(decimal rate)
		{
			if (rate != 0)
			{
				return rate.ToString("P2");
			}
			return "--";
		}
	}
}